package com.example.warehouse.mapper;

import com.example.warehouse.entity.Product;
import com.example.warehouse.page.Page1;
import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.DeleteMapping;

import java.util.List;


@Mapper
public interface ProductMapper {

    Integer getCountPage(Product product);

    List<Product> findproductPage(@Param("page") Page1 page1, @Param("product") Product product);


    @Insert("INSERT INTO product (store_id,brand_id, product_name, product_num, product_invent, type_id, " +
            "supply_id, place_id, unit_id, introduce, in_price," +
            " sale_price, mem_price,create_time,create_by, imgs, product_date, supp_date,up_down_state) values " +
            "(#{storeId},#{brandId},#{productName},#{productNum},#{productInvent},#{typeId},#{supplyId},#{placeId},#{unitId}," +
            "#{introduce},#{inPrice},#{salePrice},#{memPrice},#{createTime},#{createBy},#{imgs},#{productDate},#{suppDate},#{upDownState})")
    void addProduct(Product product);


    @Update("UPDATE product set up_down_state=#{upDownState} where product_id=#{productId}")
    void updateState(Integer productId, String upDownState);

    @Update("UPDATE product set brand_id=#{brandId},store_id=#{storeId},product_name=#{productName},product_num=#{productNum}," +
            "product_invent=#{productInvent},type_id=#{typeId},supply_id=#{supplyId},place_id=#{placeId},unit_id=#{unitId},introduce=#{introduce}," +
            "in_price=#{inPrice},sale_price=#{salePrice},mem_price=#{memPrice},update_time=#{updateTime},update_by=#{updateBy},imgs=#{imgs}," +
            "product_date=#{productDate},supp_date=#{suppDate} where product_id=#{productId}")
    void updateProduct(Product product);


    void deleteList(List<Integer> deleteList);
}
